#include <iostream>
#define ll long long

using namespace std;

int main(){
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int t;
	cin >> t;
	while(t--){
		ll num;
		cin >> num;
		if(num % 6 == 4){
			cout << "2";
		}else{
			cout << "0";
		}
		if(t) cout << endl;
	}

	return 0;
}

